package com.liangsui.mss.controller.statistics;

import com.liangsui.mss.controller.BaseController;
import com.liangsui.mss.dto.WorkloadQueryDto;
import com.liangsui.mss.service.WorkLoadService;
import com.liangsui.mss.vo.AjaxResult;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;


@RestController
@RequestMapping("/statistics/workload")
public class StatWorkloadController extends BaseController {


	  @DubboReference
	  private WorkLoadService workloadService;

	  @GetMapping("/queryWorkload")
	  public AjaxResult queryWorkload(WorkloadQueryDto workloadQueryDto){
			System.out.println("开始时间---------------"+workloadQueryDto.getBeginTime());
			System.out.println("结束时间---------------"+workloadQueryDto.getEndTime());
			//第一次进来 为查询当天
			if(workloadQueryDto.getBeginTime() == null){
				  String date=new SimpleDateFormat("yyyy-MM-dd").format(new Date()).toString();
				  workloadQueryDto.setQueryDate(date);
			}
			return AjaxResult.success(workloadService.queryWorkload(workloadQueryDto));
	  }
	  @GetMapping("/queryWorkloadStat")
	  public AjaxResult queryWorkloadStat(WorkloadQueryDto workloadQueryDto){
	  	  if (workloadQueryDto.getBeginTime() == null){
				String date=new SimpleDateFormat("yyyy-MM-dd").format(new Date()).toString();
				workloadQueryDto.setQueryDate(date);
		  }
	  	  return AjaxResult.success(workloadService.queryWorkloadStat(workloadQueryDto));
	  }



}